package com.zqx.mediator.specificmediator;

import com.zqx.mediator.abstractcomponent.Component;
import com.zqx.mediator.abstractmediator.Mediator;
import com.zqx.mediator.specificcomponent.Button;
import com.zqx.mediator.specificcomponent.ComboBox;
import com.zqx.mediator.specificcomponent.List;
import com.zqx.mediator.specificcomponent.TextBox;


public class ConcreteMediator extends Mediator {

    public Button addButton;//维持对各个同事对象的引用
    public TextBox userNameBox;//维持对各个同事对象的引用
    public ComboBox cb;//维持对各个同事对象的引用
    public List list;

    @Override
    public void componentChanged(Component c) {
        //单击按钮
        if(c == addButton)
        {
            System.out.println("--单击增加按钮--");
            list.update();
            cb.update();
            userNameBox.update();
        }//冲列表框中选择按钮
        else if(c == list){
            System.out.println("--从列表框中选择客户");
            cb.select();
            userNameBox.setText();
        }//从组合框中选择客户
        else if(c == cb){
            System.out.println("--从组合框中选择客户--");
            cb.select();
            userNameBox.setText();

        }
    }
}
